
var vm = new Vue({
    el:'#viewapp',
    data:{
        title: null,
        payorder: {},
        selected: '',
    },
    methods: {
        getInfo: function(id){
            console.info("====2=====id:"+id);
            $.get("../payorder/info/"+id, function(r){
                console.info("====3=====id:"+r.payorder.resource);
                vm.payorder = r.payorder;
                if(r.payorder.resource==0){vm.payorder.resource="微信";
                }else if(r.payorder.resource==1){vm.payorder.resource="支付宝";}

                if (r.payorder.status == 0) {vm.payorder.status= "支付失败";
                } else if (r.payorder.status == 1) {vm.payorder.status= "已付款";
                }else if (r.payorder.status == 2) {vm.payorder.status= "已退款";
                }else if (r.payorder.status == 3) {vm.payorder.status= "已对账";
                }else if (r.payorder.status == 4) {vm.payorder.status= "已关闭";
                }else if (r.payorder.status == 5) {vm.payorder.status= "退款处理中";
                }else if (r.payorder.status == 6) {vm.payorder.status= "未确定，需重新发起";
                }else if (r.payorder.status == 7) {vm.payorder.status= "转入代发";
                }else if (r.payorder.status == 9) {vm.payorder.status= "异常";
                }else if (r.payorder.status == 10) {vm.payorder.status= "转入退款";
                }else if (r.payorder.status == 11) {vm.payorder.status= "未支付";
                }else if (r.payorder.status == 12) {vm.payorder.status= "已冲正";
                }else if (r.payorder.status == 13) {vm.payorder.status= "已撤销";
                }else{
                    vm.payorder.status= "";
                }
            });
        },
        view: function(id){
            console.log(this.$route.query.id);
        },
    }
});

$(function () {
    //获取网页参数
    (function($) {
        $.getUrlParam = function(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return unescape(r[2]);
            return null;
        }
    })(jQuery);
    orderid = $.getUrlParam('orderid');

    $("#jqGrid").jqGrid({
        url: '../payorder/list',
        postData:{
            category:1,
            orderid:orderid
        },
        datatype: "json",
        colModel: [
            {label: '订单号', name: 'recordno', index: 'recordNo', width: 100},
            {label: '订单创建时间', name: 'orderdate', index: 'orderdate', width: 85},
            {label: '商户号', name: 'busid', index: 'busId', width: 100},
            {label: '支付状态', name: 'status', index: 'status', width: 60,
                formatter: function (value, options, row) {
                    if (value == 0) {return "支付失败";
                    } else if (value == 1) {return "已付款";
                    }else if (value == 2) {return "已退款";
                    }else if (value == 3) {return "已对账";
                    }else if (value == 4) {return "已关闭";
                    }else if (value == 5) {return "退款处理中";
                    }else if (value == 6) {return "未确定，需重新发起";
                    }else if (value == 7) {return "转入代发";
                    }else if (value == 9) {return "异常";
                    }else if (value == 10) {return "转入退款";
                    }else if (value == 11) {return "未支付";
                    }else if (value == 12) {return "已冲正";
                    }else if (value == 13) {return "已撤销";
                    }else{
                        return "";
                    }
                }},
            {label: '退款类型', name: 'refundtype', index: 'refundtype', width: 40,
                formatter: function (value, options, row) {
                    if(row.category==1){
                        if (value == 0) {
                            return "部分";
                        } else if (value == 1) {
                            return "全额";
                        }else{
                            return "";
                        }
                    }else{
                        return "";
                    }
                }},
            {label: '金额', name: 'amount', index: 'amount', width: 80},
            {label: '备注', name: 'remark', index: 'remark', width: 80}
        ],
        viewrecords: false,
        height: 85,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
});

$(function() {
    //获取网页参数
    (function($) {
        $.getUrlParam = function(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return unescape(r[2]);
            return null;
        }
    })(jQuery);
    id = $.getUrlParam('id');
    console.info("====1=====id:"+id);
    vm.getInfo(id);
});